<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>NHibernate Templates - VB</title>
<style type="text/css">
.style1 {
	color: #FF0000;
}
.style2 {
	color: #FF6600;
}
</style>
</head>

<body>

<h1>NHibernate Templates - VB</h1>

<h2>Table of Contents</h2>
<ul>
<li><a href="#Overview">Overview</a></li>
<li><a href="#QuickStart">Quick Start</a></li>
<li><a href="#SampleAppConfig">Sample App.Config</li>
<li><a href="#AdvancedTips">AdvancedTips</li>
<li><a href="#Dependancies">Dependancies</li>
<li><a href="#KnownIssues">Known Issues</li>
<li><a href="#Downloads">Downloads</li>
<li><a href="#History">History</li>
<li><a href="#Links">Links</li>
</ul>



<h2><a title="Overview" name="Overview"></a>Overview</h2>
<p>
The contents of this readme (and QuickStart section) are covered in our <b><a href="http://community.codesmithtools.com/blogs/videotutorials/archive/2008/11/04/using-codesmith-nhibernate-templates.aspx">NHibernate Video Tutorial</a></b>, located on the <a href="http://community.codesmithtools.com/">CodeSmith Community</a> website.<br>
Note: This video is done in C#, but the configuration of the CSP & CST are almost identical.<br>
Also, please check the CodeSmith Examples folder (or <a href="http://codesmith.googlecode.com/svn/trunk/Templates/Examples/NHibernate/">GoogleCode Respository</a>) for a completely preconfigured NHibernate example project.
</p>
<p>
These are a collection of templates that generate code that use NHiberate Framework.<br>
These templates are designed to produce 5 major things...
<ol>
<li>NHibernate XML mapping files.</li>
<li>Business objects to match the NHibernate maps.</li>
<li>A Manager object for each business object that provide table specific access methods.</li>
<li>A NHibernateSessionManager that produces NHibernateSession objects to help abstract NHibernate ISession logic.</li>
<li>Very basic unit tests for each business object/manager.</li>
</ol>
</p>



<h2><a title="QuickStart" name="QuickStart"></a>Quick Start</h2>
<p><ol>
<li>Create a new VisualStudio project.</li>
<li>Set the project Root Namespace to be blank.</li>
<li>Add a new CodeSmith Project (CSP) to your project.
<ol>
<li>Right click on the project.</i>
<li>Select "Add new item..."</i>
<li>In Common Items there will be a CodeSmith Project.</i>
</ol></li>
<li>Add NHibernateMaster.cst to your CSP's output.</li>
<li>Configure NHibernateMaster as desired.
<ol>
<li>Don't forget to update your Assembly name!</i>
</ol></li>
<li>Create/Update your App.Config to support NHibernate (example below).
<ol>
<li>If using the sample below, update the connection string and...</li>
<li>...update the mapping assembly.</li>
</ol></li>
<li>Right click on your CSP and Generate Outputs.</li>
<li>Compile, and enjoy!</li>
</ol></p>



<h2><a title="SampleAppConfig" name="SampleAppConfig"></a>Sample App.Config</h2>
<p>
&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br>
&lt;configuration&gt;<br>
&nbsp; &lt;configSections&gt;<br>
&nbsp; &nbsp; &lt;section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /&gt;<br>
&nbsp; &lt;/configSections&gt;<br>
&nbsp; &lt;hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"&gt;<br>
&nbsp; &nbsp; &lt;session-factory&gt;<br>
&nbsp; &nbsp; &nbsp; &lt;property name="connection.provider"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/property&gt;<br>
&nbsp; &nbsp; &nbsp; &lt;property name="dialect"&gt;NHibernate.Dialect.MsSql2005Dialect&lt;/property&gt;<br>
&nbsp; &nbsp; &nbsp; &lt;property name="connection.driver_class"&gt;NHibernate.Driver.SqlClientDriver&lt;/property&gt;<br>
&nbsp; &nbsp; &nbsp; &lt;property name="connection.connection_string"&gt;&lt;/property&gt;<br>
&nbsp; &nbsp; &nbsp; &lt;mapping assembly="NHibernate.Generated"/&gt;<br>
&nbsp; &nbsp; &lt;/session-factory&gt;<br>
&nbsp; &lt;/hibernate-configuration&gt;<br>
&lt;/configuration&gt;<br>
</p>



<h2><a title="AdvancedTips" name="AdvancedTips"></a>Advanced Tips</h2>
<p>
To explicitly specify a custom name for either a column or table, add a "cs_alias" value to it's extended properties.
</p>
<p>
To explicitly specify a ManyToMany table, add a "cs_ManyToMany" value to it's extended properties.
</p>



<h2><a title="Dependancies" name="Dependancies"></a>Dependancies</h2>
<p>
These templates will only build with CodeSmith 5.0.
</p>
<p>
These templates include NHibernate version 2.0.0.Alpha1; but they can also support NHibernate 1.2.1<br>
NHibernate 1.2.1 Differences:
<ol>
<li>Supports legacy Namespaces.</li>
<li>UnitTests validate deleted rows differently.</li>
</ol>
</p>
<p>
These templates linclude NUnit 2.4.7 for .Net 2.0
</p>
<p>
These templates support both Visual Studio 2008 and 2005.<br>
Visual Studio 2005 Differences:
<ol>
<li>Does not include partial methods in business ojects.</li>
</ol>
</p>



<h2><a title="KnownIssues" name="KnownIssues"></a>Known Issues</h2>
<p>
<ul>
<li>UnitTests require that each table in the database have at least valid row.</li>
<li>Currently we do not support Composite Foriegn Keys; the columns for the keys will be generated, but the associations will not.</li>
</ul>
</p>



<h2><a title="Downloads" name="Downloads"></a>Downloads</h2>
<p>
Download the latest release from GoogleCode.
<ul>
<li><a href="http://codesmith.googlecode.com/svn/trunk/Templates/Frameworks/NHibernate/">http://codesmith.googlecode.com/svn/trunk/Templates/Frameworks/NHibernate/</a></li>
</ul>
</p>



<h2><a title="History" name="History"></a>History</h2>
<p>
<ul>
<li>Release 1.0.18
<ul>
<li>New Feature: Added ExcludedColumn property, used to specify Regular Expressions that will prevent generation of members from matching columns.</li>
</ul></li>
<li>Release 1.0.17
<ul>
<li>Bug Fix: Now Association Columns will get properties when their table is excluded.</li>
</ul></li>
<li>Release 1.0.16
<ul>
<li>Bug Fix: Updated version column logic to prevent primary key property duplication on generation.</li>
</ul></li>
<li>Release 1.0.15
<ul>
<li>Bug Fix: Changed default HBM Bag Inverse attribute to false to fix many to many persistence issue.</li>
</ul></li>
<li>Release 1.0.14
<ul>
<li>New Feature: Added Query Methods to Managers.</li>
<li>New Feature: Added Unique Query & Criteria Methods to Managers.</li>
<li class="style2">Update: Removed automatic flush on session close.</li>
</ul></li>
<li>Release 1.0.13
<ul>
<li>Bug Fix: SearchCritera was including foreign keys columns even when their associated tables were excluded.</li>
</ul></li>
<li>Release 1.0.12
<ul>
<li>Added Evict Method to Manager Objects.</li>
<li>Bug Fix: Fixed unit test issues when Entities had no Members.</li>
</ul></li>
<li>Release 1.0.11
<ul>
<li>Bug Fix: Updated UnitTests to use only non key and version columns for Update.</li>
</ul></li>
<li>Release 1.0.10
<ul>
<li>Bug Fix: Removed MembersPrimaryKeyUnion and integrated logic with Members list; this should prevent redundant properties from being created for primary key columns.</li>
</ul></li>
<li>Release 1.0.9
<ul>
<li>Update Row Version Regex; now accepts only columns named "RowVersion" or "Version".</li>
</ul></li>
<li>Release 1.0.8
<ul>
<li>Fix Row Version rutime bug in HBM.</li>
</ul></li>
<li>Release 1.0.7
<ul>
<li>Add Row Version support in HBM.</li>
</ul></li>
<li>Release 1.0.6
<ul>
<li>Added Nullable Column/Type support.</li>
</ul></li>
<li>Release 1.0.5
<ul>
<li class="style1">Reworked variable naming system.
<ul>
<li>Bug Fix: Column names will no be set to singluar for no reason.</li>
<li>Bug Fix: Better duplicate member name prevention.</li>
</ul></li>
<li>Updated ManyToMany logic.
<ul>
<li>Added RowVersion Regex.</li>
<li>Added Extended Data override (cs_ManyToMany).</li>
</ul></li>
</ul></li>
<li>Release 1.0.4
<ul>
<li>Updated HBM files to use Table.FullName.</li>
</ul></li>
<li>Release 1.0.3
<ul>
<li>Updated ManyToMany logic.</li>
</ul>
<li>Release 1.0.2
<ul>
<li class="style1">Improved logic that prevents duplication of columns and associations in the business entities.</li>
<li>Improved logic for processing Primary Keys columns</li>
<li>Refactored code to use common NHibernateHelper assembly.</li>
</ul></li>
<li>Release 1.0.1
<ul>
<li>Bug Fix: We now support creating unit test data for varchar(max).</li>
<li>New Feature: Any table or column name can be overriden by added "cs_alias" to it's extended properties.</li>
</ul></li>
<li>Release 1.0.0</li>
<ul>
<li>Initial release.</li>
</ul>
</ul>
</p>
<p>
<span class="style1">*Breaking change<span><br>
<span class="style2">*Runtime change<span>
</p>



<h2><a title="Links" name="Links"></a>Links</h2>
<p>
<a href="http://community.codesmithtools.com/forums/67.aspx/">CodeSmith NHibernate Forum</a><br>
<a href="http://community.codesmithtools.com/blogs/videotutorials/archive/2008/11/04/using-codesmith-nhibernate-templates.aspx">NHibernate Video Tutorial</a>
</p>
<p>
<a href="http://www.codesmithtools.com/">CodeSmith Tools</a><br>
<a href="http://community.codesmithtools.com/">CodeSmith Community</a><br>
</p>
<p>
<a href="http://codesmith.googlecode.com/svn/trunk/Templates/Frameworks/NHibernate/">CodeSmith GoogleCode Repository - NHibernate</a><br>
<a href="http://codesmith.googlecode.com/svn/trunk/Templates/Examples/NHibernate/">CodeSmith GoogleCode Repository - Example Project</a><br>
<a href="http://code.google.com/p/codesmith/issues/list">CodeSmith GoogleCode Repository - Issue Tracker</a>
</p>
<p>
<a href="http://www.hibernate.org/343.html">NHibernate for .NET</a>
</p>
<p>
<a href="http://www.nunit.org/">NUnit</a>
</p>
<p>
<h4>Special Thanks</h4>
<a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx">Billy McCafferty</a><br>
<a href="http://www.ayende.com/Blog/">Ayende @ Rahien</a><br>
<a href="http://www.manning.com/kuate/">NHibernate in Action</a><br>
</p>
